﻿/*
 * CsCompareType
 * 
 * initial implementation : 5.12.2008
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;


namespace Petra.Gis.ReferenceSystemServices
{
  /// <summary>
  /// describes comparation of coordinate systems
  /// in some cases not all coordinate system parameters should be compared
  /// then this enume specifies compare type
  /// </summary>
  public class CsCompareType
  {


    private int _compareMask;


    private CsCompareType(params CsCompareType[] cmask)
    {
      foreach (CsCompareType c in cmask)
        _compareMask += c._compareMask;
    }



    private CsCompareType(int mask)
    {
      _compareMask = mask;
    }




    //private int _compareMask = 0;

    /// <summary>
    /// compare all parameters of both coordinate systems
    /// except metadata
    /// </summary>
    public static readonly CsCompareType CompareAllParams = new CsCompareType(0);
    //public bool CompareAllParams = true;

    /// <summary>
    /// compare all parameters except storage units.
    /// this is usefull, when search for coordinate system in database
    /// and database contains eg. WGS84 in degrees and
    /// user data has WGS84 in radians. Both are same and ProjectionUnitTransform is applied
    /// </summary>
    public static readonly CsCompareType SkipStorageUnits = new CsCompareType(1);
    //public bool SkipStorageUnits;

    /// <summary>
    /// compare all but storage units and prime meridian
    /// this is usefull when search for coordinate system in database
    /// and database contains eg. TransverseMercator projection for 0 deg
    /// and user data has TransverseMercator 6 deg (with different false easting and northing).
    /// Both are same and MerdianShiftTransform is applied (is possible)
    /// </summary>
    public static readonly CsCompareType SkipMeridian = new CsCompareType(2);
    //public bool skipMeridian;
    //public const bool SkipMeridian = true;

    /// <summary>
    /// compare all but projection axes of 2 projected coordinate systems
    /// </summary>
    public static readonly CsCompareType SkipProjectionAxesOrientation = new CsCompareType(4);
    //public bool AllButProjectionAxes;




    public static CsCompareType Prepare(params CsCompareType[] ctypes)
    {
      return new CsCompareType(ctypes);
    }





    public static bool operator ==(CsCompareType left, CsCompareType right)
    {
      return (left._compareMask & right._compareMask) != 0;
    }




    public static bool operator !=(CsCompareType left, CsCompareType right)
    {
      return (left._compareMask & right._compareMask) == 0;
    }




    public static CsCompareType operator |(CsCompareType left, CsCompareType right)
    {
      return new CsCompareType(left, right);
    }




    public override int GetHashCode()
    {
      return base.GetHashCode();
    }



    public override bool Equals(object obj)
    {
      return base.Equals(obj);
    }
  }



}
